#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <stdlib.h>
/*int main()
{
	while(1)
	{
		//printf("I am a process!\n");
		//sleep(1);//休眠一秒
	}
	return 0;
}*/
/*
int main()
{
    int a = 0;
	while(1)
	{
        //scanf("%d",&a);
        printf("I am a process!\n");
        sleep(1);
	}
	return 0;
}*/
/*int main()
{
	pid_t id = fork();
	if(id<0)
	{
		//程序出错
		perror("fork");
		return 1;
	}
	else if(id > 0)
	{
		printf("parent[%d] is sleeping...\n",getpid());
		sleep(30);
	}
	else
	{
		printf("child[%d] is begin Z...\n",getpid());
		sleep(5);
		exit(-1);
	}
	return 0;
}*/
int main()
{
	pid_t id = fork();
	if(id<0)
	{
		//程序出错
		perror("fork");
		return 1;
	}
	else if(id > 0)
	{
		printf("parent[%d] is sleeping...\n",getpid());
		sleep(3);
		exit(-1);
	}
	else
	{
		printf("child[%d] is begin Z...\n",getpid());
		sleep(10);
	}
	return 0;
}
